<!--
 * @Author: nns4
 * @Date: 2020-02-27 17:39:16
 * @LastEditors: nns4
 * @FilePath: /citciWechartShop/src/views/test/regular.vue
 * @Description: 正则用法
 -->
 
<template>
  <div>
    <van-cell-group>
      <van-field v-model="phone" placeholder="手机号正则">
        <van-button @click="PhoneTest" slot="button" size="small" type="primary">验证</van-button>
      </van-field>
      <van-field v-model="parseIntNmber" placeholder="正整数正则">
        <van-button @click="ParseIntTest" slot="button" size="small" type="primary">验证</van-button>
      </van-field>
    </van-cell-group>
  </div>
</template>
<script>
import regular from "@lib/regular.js";
export default {
  name: "regular",
  data() {
    return {
      phone: null,
      parseIntNmber: null
    };
  },
  mounted() {},
  methods: {
    PhoneTest() {
      regular('phone',this.phone)
        .then(res => this.$toast.success("验证通过"))
        .catch(res => {
          this.$toast.fail("验证失败");
        });
    },
    ParseIntTest() {
      regular('positiveInteger',this.parseIntNmber)
        .then(res => this.$toast.success("验证通过"))
        .catch(res => {
          this.$toast.fail("验证失败");
        });
    }
  }
};
</script>
<style lang="less" scoped>
</style>